// include StringFunctions.js
//document.write("<script type="text/javascript" src = "StringFunctions.js"></script>" );

/*
 Shortcut to get a document element by id.
*/
function $(id)
{
    return document.getElementById(id);
}

/*
 Call update method if user presses Shift+Enter.
*/
function keypress(key)
{
    var code = key.charCode;
    if( code == 0 || code == undefined)
        code = key.keyCode;
        
    if(code == 13 && key.shiftKey)
        update();
}    

/*
 Pass the expression from the input box to the parser.
*/
function update()
{
    var input = $("inputBox").value;
    
    $("instructionsBox").value = "test";
    
    //testing chompOffFirstChar
    /*
    var testStr = "hello world";
    //var testStr = " hello world"; //this will just get one space removed
    //testStr = "a"; //single char
    //testStr = ""; //empty str
    alert("testStr before: " + testStr);
    testStr = chompOffFirstChar(testStr); 
    alert("testStr after chomping: " + testStr);
    */
    
    //testing isBlankChar
    //alert("c: " + isBlankChar("c"));
    //alert(" c: " + isBlankChar(" c"));
    //alert("dog: " + isBlankChar("dog"));
    //alert("doublespace: " + isBlankChar("  "));
    //alert("space: " + isBlankChar(" "));
    //alert("tab: " + isBlankChar("\t"));
    //alert("newline: " + isBlankChar("\n"));
    //alert("carriage\rreturn: " + isBlankChar("\r"));

    //testing skipLeadingBlanks
    /*
    //var word = "hello world";
    //var word = "          hello world";
    //var word = " ";
    var word = "";
    alert("word before: " + word);
    word = skipLeadingBlanks(word);
    alert("word after: " + word);
    */
    
    //testing getFirstChar
    /*
    //var word = "hello";
    //var word = "h";
    var word = ""; //returns undefined
    alert("first char: " + getFirstChar(word));
    */
    
    //testing getFirstWord
    /*
    //var word = "hello world";
    //var word = "hello";
    //var word = "          hello world";
    //var word = " ";
    var word = "";
    alert("word before: " + word);
    var first = getFirstWord(word);
    alert("first word: " + first);
    alert("word after: " + word);
    */
    
    //testing chompOffFirstWord
    /*
    //var word = "hello world";
    //var word = "hello";
    //var word = "          hello world";
    //var word = " ";
    var word = "";
    alert("word before: " + word);
    word = chompOffFirstWord(word);
    alert("word after: " + word);
    */
    
    var table = new hash_atoms();
    
    alert( "has item: " + getTruthValue("hello", table) );
    
    alert( "has item: " + getTruthValue("world", table) );
    
    alert("table length: " + table.length);
    
    alert("table items: " + table.items.length);
    
    /*
    for(var i=0; i<table.items.length; i++)
    {
        alert(i + ": " + tablie.items[i]);
    }
    */
    
    alert("done.");
}


